#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int jump(vector<int>& nums)
    {
        int n = nums.size();
        int left = 0, right = 0;
        int count = 0;
        while (right < n - 1)
        {
            int tmp = right;
            for (int i = left; i <= tmp; i++)
            {
                right = max(right, nums[i] + i);
            }
            left = tmp + 1;
            count++;
        }
        return count;
    }
};